﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using NewDDSys.Entity;
using NewDDSys.IBLL;
using NewDDSys.IDAL;
using NewDDSys.Factory;
using NewDDSys.Utility;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Web_UptDxc : System.Web.UI.Page
{
    private string num = "";
    private int cs = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        num = Request.QueryString["Num"];
        DataSet ds = BLLFactory.CreateDxcBLL().SelectNum(num);
        
        cs = Convert.ToInt32(ds.Tables[0].Rows[0]["cs"].ToString());
        if(!IsPostBack)
        {
            txtNUM.Text = num;
            txtNUM.Attributes["contentEditable"] = "false";
            txtKU.Text = ds.Tables[0].Rows[0]["ku"].ToString();
            txtKU.Attributes["contentEditable"] = "false";
            txtNeirong.Text = ds.Tables[0].Rows[0]["neirong"].ToString();
            txtNeirong.Attributes["contentEditable"] = "false";
            txtCs.Text = cs.ToString();
            txtDun.Text = ds.Tables[0].Rows[0]["dun"].ToString();
        }
        
    }
    protected void btnUpt_Click(object sender, EventArgs e)
    {
        if (cs != Convert.ToInt32(txtCs.Text.ToString()))
        {
            DataSet ds = BLLFactory.CreateWorkBLL().Select(num);
            int good = Convert.ToInt32(ds.Tables[0].Rows[0]["good"].ToString());
            int wc = good - Convert.ToInt32(txtCs.Text.ToString());
            BLLFactory.CreateWorkBLL().UpdateWcs(num, wc);


        }
        int f = BLLFactory.CreateDxcBLL().Update(num, Convert.ToInt32(txtCs.Text.ToString()), Convert.ToDecimal(txtDun.Text.ToString()));
        if (f >= 1)
        {
            Response.Write(" <script   language=javascript> window.alert( ' 修改成功！ ');</script> ");
            BLLFactory.CreateDxcBLL().UpdateXG(num, DateTime.Now.ToString());
        }
            
        Response.Redirect("DXCJL.aspx");
    }
}
